package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class MaximumValueInTwoDimensionalArray {
	public static void main(String[] argv) {
		double[][] arr = new double[2][2];
		arr[0][0] = 34.45;
		arr[0][1] = 34.45;
		arr[1][0] = 36.67;
		arr[1][1] = 37.78;
		System.out.println("二维数组中的最大值:" + maximum(arr));
	}

	public static double maximum(double[] arr) {
		double maxVal = Double.NEGATIVE_INFINITY;
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] > maxVal) {
				maxVal = arr[i];
			}
		}
		return maxVal;
	}

	public static double maximum(double[][] arr) {
		double maxVal = Double.NEGATIVE_INFINITY;
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] != null) {
				maxVal = Math.max(maxVal, maximum(arr[i]));
			}
		}
		return maxVal;
	}

}
